﻿using System;
using System.ComponentModel;
using System.Web;
using System.Windows.Forms;
using SinaWeiboPlugin.Properties;
using Slippor.Douban.Radio.Assist;

namespace SinaWeiboPlugin
{
    internal partial class UploadForm : Form
    {
        private TweetBuilder _builder;

        public UploadForm(TweetBuilder builder)
        {
            InitializeComponent();

            _builder = builder;
            uploadControl.Builder = _builder;
            fortuneTellerControl.Builder = _builder;
            configControl.Closed += new EventHandler(configControl_Closed);

            UpdateInfo();
            RefreshFortuneList();
        }

        private void configControl_Closed(object sender, EventArgs e)
        {
            linkLabelConfig.Text = "设置";
            configControl.Visible = false;
        }

        public void UpdateInfo()
        {
            uploadControl.UpdateInfo();
        }

        public void RefreshFortuneList()
        {
            fortuneTellerControl.RefreshFortuneList();
        }

        public void SendFortune(Fortune fortune)
        {
            fortuneTellerControl.SendFortune(fortune);
        }

        public void Update(Fortune fortune)
        {
            fortuneTellerControl.Update(fortune);
        }

        private void linkLabelConfig_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (linkLabelConfig.Text == "设置")
            {
                linkLabelConfig.Text = "返回";
                configControl.Visible = true;
                configControl.ShowTabPage(tabControlUpload.SelectedIndex + 1);
            }
            else
            {
                linkLabelConfig.Text = "设置";
                configControl.Visible = false;
            }
        }
    }
}
